package com.pai4j.remote.ugc;

import com.pai4j.common.bean.PAIPageResponseBeanUtil;
import com.pai4j.common.bean.PAIResponseBean;
import com.pai4j.domain.vo.request.community.CreateCommunityContributionRequestVO;
import com.pai4j.domain.vo.request.community.UpdateCommunityContributionRequestVO;
import com.pai4j.domain.vo.request.community.ContributionStatusChangeRequestVO;
import com.pai4j.domain.vo.response.community.CommunityContributionBaseResponseVO;
import com.pai4j.domain.vo.response.community.CommunityContributionDetailResponseVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 社区共建远程接口
 *
 * @author: CYM-pai
 * @date: 2025/07/30 12:00
 **/
@FeignClient(name = "pai4j-ugc-service", contextId = "communityContributionClient")
public interface CommunityContributionClient {

    /**
     * 创建社区共建
     *
     * @param createRequest 创建请求
     * @return 共建ID
     */
    @PostMapping("/ugc-service/community/contribution/create")
    PAIResponseBean<Long> create(@RequestBody CreateCommunityContributionRequestVO createRequest);

    /**
     * 更新社区共建
     *
     * @param updateRequest 更新请求
     * @return 更新结果
     */
    @PostMapping("/ugc-service/community/contribution/update")
    PAIResponseBean<Boolean> update(@RequestBody UpdateCommunityContributionRequestVO updateRequest);

    /**
     * 删除社区共建
     *
     * @param contributionId 共建ID
     * @param operator       操作人
     * @return 删除结果
     */
    @DeleteMapping("/ugc-service/community/contribution/delete/{contributionId}")
    PAIResponseBean<Boolean> delete(@PathVariable Long contributionId, @RequestParam String operator);

    /**
     * 获取共建详情
     *
     * @param contributionId 共建ID
     * @return 共建详情
     */
    @GetMapping("/ugc-service/community/contribution/detail/{contributionId}")
    PAIResponseBean<CommunityContributionDetailResponseVO> detail(@PathVariable Long contributionId);

    /**
     * 分页查询共建列表
     *
     * @param pageNo    页码
     * @param pageSize  页大小
     * @param submitter 提交人（可选）
     * @param assignee  处理人（可选）
     * @param type      类型（可选）
     * @param status    状态（可选）
     * @param priority  优先级（可选）
     * @param category  分类（可选）
     * @param title     标题关键词（可选）
     * @return 分页共建列表
     */
    @GetMapping("/ugc-service/community/contribution/list")
    PAIResponseBean<PAIPageResponseBeanUtil<List<CommunityContributionBaseResponseVO>>> list(
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "submitter", required = false) String submitter,
            @RequestParam(value = "assignee", required = false) String assignee,
            @RequestParam(value = "type", required = false) Integer type,
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "priority", required = false) Integer priority,
            @RequestParam(value = "category", required = false) String category,
            @RequestParam(value = "title", required = false) String title);

    /**
     * 查询用户提交的共建列表
     *
     * @param userId   用户ID
     * @param pageNo   页码
     * @param pageSize 页大小
     * @param status   状态（可选）
     * @return 分页共建列表
     */
    @GetMapping("/ugc-service/community/contribution/my/{userId}")
    PAIResponseBean<PAIPageResponseBeanUtil<List<CommunityContributionBaseResponseVO>>> listBySubmitter(
            @PathVariable String userId,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "status", required = false) Integer status);

    /**
     * 查询处理人的共建列表
     *
     * @param userId   用户ID
     * @param pageNo   页码
     * @param pageSize 页大小
     * @param status   状态（可选）
     * @return 分页共建列表
     */
    @GetMapping("/ugc-service/community/contribution/assigned/{userId}")
    PAIResponseBean<PAIPageResponseBeanUtil<List<CommunityContributionBaseResponseVO>>> listByAssignee(
            @PathVariable String userId,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "status", required = false) Integer status);

    /**
     * 变更共建状态
     *
     * @param statusChangeRequest 状态变更请求
     * @return 变更结果
     */
    @PostMapping("/ugc-service/community/contribution/status/change")
    PAIResponseBean<Boolean> changeStatus(@RequestBody ContributionStatusChangeRequestVO statusChangeRequest);

    /**
     * 分配处理人
     *
     * @param contributionId 共建ID
     * @param assignee       处理人
     * @param operator       操作人
     * @return 分配结果
     */
    @PostMapping("/ugc-service/community/contribution/assign/{contributionId}")
    PAIResponseBean<Boolean> assign(@PathVariable Long contributionId,
                                   @RequestParam String assignee,
                                   @RequestParam String operator);

    /**
     * 获取统计信息
     *
     * @return 统计信息
     */
    @GetMapping("/ugc-service/community/contribution/statistics")
    PAIResponseBean<Map<String, Object>> getStatistics();

    /**
     * 获取用户仪表板数据
     *
     * @param userId 用户ID
     * @return 仪表板数据
     */
    @GetMapping("/ugc-service/community/contribution/dashboard/{userId}")
    PAIResponseBean<Map<String, Object>> getUserDashboard(@PathVariable String userId);
}
